package com.gy.smart.mine;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gy.smart.R;
import com.gy.smart.base.BaseActivity;
import com.gy.smart.util.AnimUtil;
import com.gy.smart.util.DataCleanManager;
import com.gy.smart.util.SharedPrefUtil;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * 作者：gy on 17/1/5
 * 说明：我的主页
 */
public class MineActivity extends BaseActivity {

    private ImageView imgHead;
    private TextView tvName,tvLogout;
    private LinearLayout llSave,llClear,llSuggestion,llIntroduc;

    @Override
    protected void initView() {
        setContentViewRes(R.layout.activity_mine_home);
        setTitleMsg("我的");
        imgHead = (ImageView) findViewById(R.id.activity_mine_img_person);
        tvName = (TextView) findViewById(R.id.activity_mine_tv_name);
        tvLogout = (TextView) findViewById(R.id.activity_mine_tv_logout);
        llSave = (LinearLayout) findViewById(R.id.activity_mine_ll_save);
        llClear = (LinearLayout) findViewById(R.id.activity_mine_ll_clear);
        llSuggestion = (LinearLayout) findViewById(R.id.activity_mine_ll_suggestion);
        llIntroduc = (LinearLayout) findViewById(R.id.activity_mine_ll_introduc);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setListener() {
        super.setListener();
        imgHead.setOnClickListener(this);
        tvName.setOnClickListener(this);
        tvLogout.setOnClickListener(this);
        llSave.setOnClickListener(this);
        llClear.setOnClickListener(this);
        llSuggestion.setOnClickListener(this);
        llIntroduc.setOnClickListener(this);
    }

    @Override
    protected void fillData() {
        super.fillData();
        if(SharedPrefUtil.get("login",false)){
            //如果已经登录

        } else {
            tvLogout.setVisibility(View.GONE);
        }
    }

    @Override
    public void doClick(View v) {
        super.doClick(v);
        Intent intent;
        switch (v.getId()){
            case R.id.activity_mine_img_person:
            case R.id.activity_mine_tv_name:
                if(!SharedPrefUtil.get("login",false)){
                    intent = new Intent(this,LoginActivity.class);
                    startActivity(intent);
                    AnimUtil.pushLeftInAndOut(this);
                }
                break;
            case R.id.activity_mine_tv_logout:
                SharedPrefUtil.put("login",false);
                finish();
                break;
            case R.id.activity_mine_ll_save:

                break;
            case R.id.activity_mine_ll_clear:
                ImageLoader.getInstance().clearDiskCache();
                ImageLoader.getInstance().clearMemoryCache();
                DataCleanManager.clearAllCache(this);
                String size2 = "";

                try {
                    size2 = DataCleanManager.getTotalCacheSize(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                showToast("清除成功");
                break;
            case R.id.activity_mine_ll_suggestion:

                break;
            case R.id.activity_mine_ll_introduc:

                break;
        }
    }
}
